package cn.itcast.oa.service.impl;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.oa.base.DaoSupportImpl;
import cn.itcast.oa.domain.User;
import cn.itcast.oa.service.UserService;


@Service
@Transactional
public class UserServiceImpl extends DaoSupportImpl<User> implements UserService{

	@Override
	public User findByLoginNameAndPassword(String loginName, String password) {
		//使用密码的MD5摘要进行对比
		
		String md5digest = DigestUtils.md5Hex(password);
		return (User) getSession().createQuery(
				"FROM User u where u.loginName=? and u.password=?")
				.setParameter(0, loginName)
				.setParameter(1, md5digest)
				.uniqueResult();
				
	}

}
